{literal}
<h2>Pager</h2>
DomPager will help to create pages to your site. 
See samples below:

<pre class="code">
&lt;?php
// lets say we have sample article table.
$total = 0; // we do not know total number of items yet.
$perPage = 20; // We want to show 20 items per page.
$link = 'http://mySite.com/articles/'; // Link where page links should direct to.
$pager = new DomPager( $total, $perPage, $link );

// now lets make our query
$items = DomSql::selectQuery('SELECT id, title FROM articles LIMIT ' .$pager->getLimit() . ' ');

// lets get total amount of articles
$total = DomSql::selectOneQuery('SELECT count(*) as n FROM articles ', 'n');
// lets update pager
$pager->setTotal( $total );

// now we are ready to output pages
foreach( $pager->getPages() as $page ) {
	if( $page['selected'] ) {
		echo '&lt;a href="'.$page['link'].'"&gt;&lt;b&gt;'.$pager['name'].'&lt;/b&gt;&lt;/a&gt;';
	else
		echo '&lt;a href="'.$page['link'].'"&gt;'.$pager['name'].'&lt;/a&gt;';
}
?&gt;
</pre>

<b>NB!</b>DomPager uses GET variable to know on which page user is. Previous example would create links:<br>
http://mySite.com/articles/&lk=0<br>
http://mySite.com/articles/&lk=1<br>
http://mySite.com/articles/&lk=2<br>
...<br>
Variable name lk can be changed using setVar($varName) method.<br>

<h2>More useful sample</h2>
This sample creates ArticlesController class and uses pager to create articles list.
<pre class="code">
&lt;?php
class MyController extends DomController {

	public function articles() {
		$this->view->setTemplate('myArticlesList.html');
	
		$pager = new DomPager(0, 20, $this->getUrl('articles/') );
		$iterator = DomSqlQuery::c()
			->countFoundRows()
			->select('id,title')
			->from('articles')
			->limit( $pager->getLimit())
			->commit();
		$pager->setTotal( $iterator->foundRows() );
		
		// access all pages
		$this->view->pages = $pager->getPages();
		$this->view->data = $iterator->toArray();
	}
}
?&gt;
</pre>
myArticlesList.html content would be something like this: (Smarty/DomView)
<pre class="code">
{foreach item=i from=$pages}
	{if $i.selected}
		&lt;a href="{$i.link}"&gt;&lt;b&gt;{$i.name}&lt;/b&gt;&lt;/a&gt;
	{else}
		&lt;a href="{$i.link}"&gt;{$i.name}&lt;/a&gt;
	{/if}
{/foreach}
&lt;br&gt;
{foreach item=i from=$data}
	Article: {$i.title}&lt;br&gt;;
{/foreach}
</pre>

{/literal}